home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Utilities Professional 1-1500
/
Utilities Professional 1-1500 (1994)(WPD)[!].iso
/
07511000
/
var0859.dms
/
var0859.adf
/
MacSound2Amy
(
.txt
)
< prev
next >
Wrap
AmigaBASIC Source Code
|
1989-08-10
|
2KB
|
85 lines
REM Convert Mac sound files to Amiga Format
REM David Q. King May 14, 1989
CLEAR ,80000
FILES
INPUT "Enter file name to convert";n$
OPEN n$ FOR INPUT AS #10
INPUT "Enter guestimate of samples per second for playback";freq%
ld&=LOF(10) 'length of sample
PRINT "file ";n$;" is ";ld&;" samples long."
OPEN n$+".8SVX" FOR OUTPUT AS #11
PRINT "output file is open as "n$".8SVX"
e$="FORM 8SVXVHDR NAME "+n$+"BODY "
REM fill in blanks in e$
formLength&=LEN(e$)-8+ld&
REM insert length of whole enchilada
CALL InsLong(4,formLength&)
REM insert length of name text
ln&=LEN(n$)
CALL InsLong(INSTR(e$,"NAME")+4,ln&)
REM insert length of body
CALL InsLong(INSTR(INSTR(e$,"NAME")+4+ln&,e$,"BODY")+4,ld&)
REM fill in fields in VHDR
v&=INSTR(e$,"VHDR")+4
CALL InsLong(v&,ld&) 'number of samples
CALL InsLong(v&+4, 0) 'repeatHiSamples = 0 for one shot
CALL InsLong(v&+8, 0) 'samplesPerHiCycle = 0 for one shot sample
CALL InsShort(v&+12, freq%) 'samples per second
CALL InsByte(v&+14, 1) 'ctOctave = 1 for one shot
CALL InsByte(v&+15, 0) 'no data compression
MID$(e$,v&+16,4)=MKS$(1) 'playback volume = 1.0 (maximum)
PRINT #11,e$; 'print header
PRINT "Converting..."
REM convert mac sample range to signed byte for amiga
n&=ld&
WHILE n&>0
c&=1000
IF n& > c& THEN 'set max size to read
n&=n&-c&
ELSE
c&=n&
n&=0
END IF
d$=INPUT$(c&,10) 'read a chunk'
PRINT ".";
FOR i&=1 TO c&
x%=ASC(MID$(d$,i&,1))-128
IF x% < 0 THEN x%=256+x%
MID$(d$,i&,1)=CHR$(x%)
NEXT i&
PRINT#11,d$; 'print a chunk
WEND
CLOSE(11)
PRINT "Done!"
END
REM GOSUB ShowD
END
SUB InsLong(p&, x&) STATIC
MID$(e$,p&,4)=MKL$(x&)
END SUB
SUB InsShort(p&, x%) STATIC
MID$(e$,p&,2)=MKI$(x%)
END SUB
SUB InsByte(p&, x%) STATIC
MID$(e$,p&,1)=CHR$(x%)
END SUB